# 安装requests
# pip install requests
# 国内源
# 清华源：
# python -m pip install --upgrade pip
# pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

import requests
query = input("输入一个你喜欢的明星")
url = f'https://www.sogou.com/web?query={query}'
dic = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"
}

resp = requests.get(url, headers=dic)
print(resp)
#print(resp.text) #获取源代码

#写入html文件
with open(f"爬到的数据/{query}.html", mode="w", encoding="utf-8") as f:
    f.write(resp.text)
resp.close()

